package com.hualan.sfzy.controller.course;

import com.hualan.sfzy.entity.course.CourseOrder;
import com.hualan.sfzy.service.course.CourseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseOrderController {
    @Autowired
    private CourseOrderService courseOrderService;
    @PostMapping("/courseOrder")
    public String add(@RequestBody CourseOrder courseOrder) {
        return courseOrderService.add(courseOrder)>0?"success":"fail";
    }
    @PutMapping("/courseOrder")
    public String update(@RequestBody CourseOrder courseOrder) {
        return courseOrderService.edit(courseOrder)>0?"success":"fail";
    }
    @DeleteMapping("/courseOrder")
    public String remove(Integer[] ids) {
        return courseOrderService.removeBatch(ids)>0?"success":"fail";
    }
    @DeleteMapping("/courseOrder/{id}")
    public String removeBatch(@PathVariable Integer id) {
        return courseOrderService.remove(id)>0?"success":"fail";
    }
    @GetMapping("/courseOrder/{id}")
    public CourseOrder get(@PathVariable Integer id) {
        return courseOrderService.findById(id);
    }
    @GetMapping("/courseOrder")
    public List<CourseOrder> find() {
        return courseOrderService.find();
    }
    @GetMapping("/courseOrder/page")
    public Object findPage(
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")
            Integer pageNum,
            @RequestParam(value = "pageSize",required = false,defaultValue = "5")
            Integer pageSize,
            CourseOrder courseOrder) {
        return courseOrderService.findPage(pageNum, pageSize, courseOrder);
    }
}

